<html>
<head>
	<meta charset='utf-8' />
	<title>小区信息助手</title>
	<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
	<style>
		
		@media screen and (max-width:450px){
			#content{width:98%;margin:0 auto;border:1px solid}
			/*页面宽度900以下时 .abc的宽度为450*/
		}
		@media screen and (min-width:450px){
			#content{width:450px;margin:0 auto;border:1px solid}
			/*页面宽度900以下时 .abc的宽度为450*/
		}
	</style>
</head>
<body id='content'>
	<div style='height:100%' id='main' class='l1'>

		<div style='text-align:left;margin:5px;font-size:12px'>
			<a href="index.html" style='text-decoration:none'>首页</a>
		</div>

		<h2 style='text-align:center'>创建小区</h2>

		<div style='text-align:center;font-size:12px;margin:20px 0'>当前城市：<span id='current_county'></span></div>


		<div style='width:250px;margin:0 auto'>
			小区名：
			<input type="text" id='area_name' />
		</div>
		<div style='width:250px;margin:10px auto;positon:relative'>
			验证码：
			<input style='width:50px' type="text" id='code' />
			<img src="interface.php?type=get_code" onclick='this.src=this.src+"&m="+Math.random()' alt='点击' style='width:70px;height:30px;position:absolute;margin-left:15px' alt="">
		</div>

		<div style='margin:20px auto;text-align:center'>
			<button id='submit'>提交</button>
			<button id='back'>返回</button>
		</div>

	</div>



</body>
</html>
<script src='../public/jquery.js'></script>
<script src='../public/fun.js'></script>
<script>
var current_county;
$(function(){
	//C(localStorage);
	if(localStorage.current_county){
		current_county = JSON.parse(localStorage.current_county);
	}else{
		location.replace('index.html');
	}
	$('#current_county').text(current_county.name);	//显示当前县名

	$('#back').click(function(){
		location.replace('index_me.html');
	});

	$('#submit').click(function(){
		var area_name = $('#area_name').val().trim();
		var vcode = $('#code').val().trim();
		if(!area_name || !code){
			return;
		}
		var data = {
			type:'create_area',
			area_name:area_name,
			vcode:vcode,
			db_host:current_county.db_host,
			db_name:current_county.db_name,
			city_code:current_county.code,
			openid:JSON.parse(localStorage.beforeUserInfo).openid
		}
		Ajax2(data,function(res){
			C(res);
			switch(res){
				case 'ok':A('创建成功，等待审核。');location.replace('index_me.html');break;
				case 'err1':A('缺少参数！');break;
				case 'err2':A('验证码不正确！');break;
				case 'err3':A('该小区正在审核中！');break;
				case 'err4':A('该小区已存在！');break;
				case 'err5':A('小区已封禁！');break;
				case 'err6':A('出现异常！');break;
			}
		});
	});
});
</script>